package com.gsafety.wellsfort.domain.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class KnowledgeResultVO {
    @ApiModelProperty(value = "角色id")
    private Integer roleId;
    @ApiModelProperty(value = "角色名称")
    private String roleName;
    @ApiModelProperty(value = "角色权限")
    private List<MenuResultVO> list;

    public void addMenu(MenuResultVO menuResultVO) {
        if (list == null) {
            list = new ArrayList<>();
        }
        list.add(menuResultVO);
    }

    public void setMenuSelect(Integer menuId) {
        if (list == null && list.size() == 0) {
            return;
        }
        for (MenuResultVO menuResultVO : list) {
            if (menuResultVO.getMenuId().equals(menuId)) {
                menuResultVO.setSelected(true);
                return;
            }
        }
    }
}
